
#include <stdio.h>

#include "modules/audio_processing/aecm/echo_control_mobile.h"
using namespace webrtc;

int main(void)
{
    int ret;

    void* aec = WebRtcAecm_Create();
    printf("WebRtcAecm_Create: ret %p\r\n", aec);

    ret = WebRtcAecm_Init(aec, 16000);
    printf("WebRtcAecm_Init: ret %d\r\n", ret);
    
    AecmConfig config;
    config.cngMode = 0;
    config.echoMode = 1; /* 激进程度0~4 */
    ret = WebRtcAecm_set_config(aec, config);
    printf("WebRtcAecm_set_config: ret %d\r\n", ret);

    /* 1x16000 10ms 远端音频数据 */
    int16_t far[160] = {0};
    ret = WebRtcAecm_BufferFarend(aec, far, 160);
    printf("WebRtcAecm_BufferFarend: ret %d\r\n", ret);

    /* 1x16000 10ms 近端音频数据 */
    int16_t nearIn[160] = {0};
    int16_t nearOut[160] = {0};
    /* 回声时间差ms */
    int16_t msInSndCardBuf = 200; 
    ret = WebRtcAecm_Process(
        aec,
        nearIn,
        NULL,
        nearOut,
        160,
        msInSndCardBuf);
    printf("WebRtcAecm_Process: ret %d\r\n", ret);

    WebRtcAecm_Free(aec);
    printf("WebRtcAecm_Free\r\n");
    return 0;
}
